﻿///<reference path="../../../../Scripts/jquery-1.4.1-vsdoc.js"/>
///<reference path="../utils/Utils.js"/>



function MainPaneController(controlId) {
    ///private properties/////////////
    this.controlId = controlId;
    this.control;
    

    ///public properties//////////////      
    this.TabsManager;

    this.Init = function () {
        this.control = $("#" + this.controlId);

        this.TabsManager = new TabsManager("MainTabs");
        this.control.append(this.TabsManager.GetContainer());
        this.TabsManager.Render(); //  только после того, как добавили на страницу
        this.TabsManager.AddTab();
        this.TabsManager.AddSystemTab();
    }

    this.GetActiveBibleBookPane = function () {
        return this.TabsManager.GetActiveTab().GetBibleBookPane();
    }

    this.ShowBook = function (bookKey) {
        //$(event.target).addClass("selected1");
        this.TabsManager.GetActiveTab().ClearWelcomePane();   // если будет уже очищено - то трогать его не будет
        var activeBiblePane = this.GetActiveBibleBookPane();
        activeBiblePane.ShowBook(bookKey);
        this.TabsManager.SetActiveTabTitle(activeBiblePane.GetCurrentBook().Title);
    }

    this.ShowBookChapter = function (chapterKey) {
        //$(event.target).addClass("selected1");
        this.TabsManager.GetActiveTab().ClearWelcomePane();
        var activeBiblePane = this.GetActiveBibleBookPane();
        activeBiblePane.ShowBookChapter(chapterKey);
        this.TabsManager.SetActiveTabTitle(activeBiblePane.GetCurrentBook().Title);
    }

    this.HighlightVerse = function (verseKey, searchPattern) {
        this.GetActiveBibleBookPane().HighlightVerse(verseKey, searchPattern);
    }

    this.OnBookViewChanged = function () {
        this.GetActiveBibleBookPane().OnBookViewChanged();
    }

    this.ClearUI = function () {
        this.TabsManager.GetActiveTab().ResetWelcomePane();
    } 
}